﻿@model Model.AppUserList
@{
    ViewBag.Title = "DCThirdInfo";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-add", function () {
            $('#hiddenTHIRDID').val();
            HandleDialog.OpenDialogByAdd('dlg', '添加第三方信息', function () {
                HandleData.ClearForm('location');
                $('#sstatus').combobox('setValue', '1');
                $('#sWareHouseId').combobox('setValue', '0');

            });
        });

        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            edit(row);
        });

        HandleDom.ClassTriggerClick("icon-reload", function () {
            InitGrid();
        });

        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑第三方信息', function () {
                $('#hiddenTHIRDID').val(row.THIRDID);
                $('#stxtThirdName').val(row.THIRDNAME);
                HandleData.SetValueComboBox('sstatus', row.STATUS);
                HandleData.SetValueComboBox('sWareHouseId', row.WAREHOUSEID);
            });
        }

        function saveData(isClose) {
            HandleRequest.submitForm('location', '@Url.Action("SaveData", "DCThirdInfo")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }

            });
        }

        function InitGrid() {
            var ThirdName = $('#txtThirdName').val();
            var Status = $('#status').combobox('getValue');


            queryParams = {
                ThirdName: ThirdName,
                Status: Status
            }
            HandleData.InitDataGrid('dg', '/DCThirdInfo/InitJsonResult', 'toolbar', queryParams, 'THIRDID', true, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>第三方名称:
                    </td>
                    <td>
                        <input id="txtThirdName" name="txtThirdName" style="width: 154px" />
                    </td>
                    <td>状态:
                    </td>
                    <td>
                        <select id="status" class="easyui-combobox" name="status" style="width: 154px;">
                            <option value="">--全部--</option>
                            <option value="0">失效</option>
                            <option value="1">生效</option>
                        </select>
                    </td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">查询</a>
                    </td>
                </tr>


            </table>
        </form>
    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="第三方信息" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'THIRDID',width:30" hidden>第三方ID</th>
                    <th data-options="field:'THIRDNAME',width:50">第三方名称</th>
                    <th data-options="field:'WAREHOUSENAME',width:50">对接仓库</th>
                    <th data-options="field:'STATUS',width:30,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatValid(value);}">状态</th>
                    <th data-options="field:'OPRNO',width:50">创建人</th>
                    <th data-options="field:'CREATEDATE',width:100,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatDate(value);}">创建时间</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 620px; height: 250px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>第三方名称:
                    </td>
                    <td>
                        <input id="hiddenTHIRDID" name="hiddenTHIRDID" type="hidden" />
                        <input id="hiddenTHIRDNAME" name="hiddenTHIRDNAME" type="hidden" />
                        <input id="stxtThirdName" name="stxtThirdName" maxlength="20" style="width: 154px" class="easyui-validatebox" data-options="required:true" />
                    </td>
                    <td>仓库:
                    </td>
                    <td>
                        <input id="sWareHouseId" class="easyui-combobox"  name="sWareHouseId" style="width: 155px;" data-options="required:true,valueField:'WAREHOUSEID',textField:'WAREHOUSENAME',url:'@Url.Action("GetDCWarehouseList", "DCWarehouse", new { isDefault = true, defaultValue = "请选择仓库" })',editable:false">
                    </td>

                </tr>
                <tr>
                    <td>状态:
                    </td>
                    <td>
                        <select id="sstatus" class="easyui-combobox" name="sstatus" style="width: 154px;">
                            <option value="0">失效</option>
                            <option value="1">生效</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(false)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =true },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =true },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =false },
              new FunctionModule(){Name = "AllAdd",IsEnable =false },
              
              
            }
        }
    }
})

</body>
